<?php

require FCPATH . 'application/controllers/frontend.php';

class Job extends Frontend {

    public function __construct() {
	parent::__construct();

	$this->load->model('job_model', 'model');
    }

    public function records() {
	$page = intval($this->input->get('page'));
	$page_size = intval($this->input->get('pageSize'));
	$page = $page ? $page : 1;
	$offset = $page_size * ($page - 1);

	$this->json_back('XT001', '', array(
	    'total' => $this->model->total(),
	    'records' => $this->model->frontend_records($page_size, $offset)
	));
    }

    public function find() {
	$id = intval($this->input->get('id'));
	
	if (!($data = $this->model->frontend_find($id))) {
	    $this->json_back('XT002', '该记录已被删除,或ID有误。');
	}
	
	$this->json_back('XT001', '', $data);
    }

}